Trained Cascade.xml file format error not able to use in C#

by: derickloo, 7 years ago


Hi, I have follow the python tutorial to trained a cascade.xml file and it succeed trained the file.  I use the file in python to detect the object I train and it success detect the object.  While I use the same cascade.xml file in the windows programming c# and it give me an error "The node does not represent a user object (unknown type?)".  May I know the trained xml file is only suitable in python?  Thanks a lot.



You must be logged in to post. Please login or register an account.



Trained XML should work from varying langs. I suspect your issue is you're using the training output rather than the actual FINISHED result. While training, you run something like:

opencv_traincascade -data data -vec positives.vec -bg bg.txt -numPos 1800 -numNeg 900 -numStages 50 -w 20 -h 20


So there we did say 50 stages. If you stop before 50, you don't get the real output, just the training data along the way, and that "latest" XML file is NOT your haar cascade. If you attempt to use it, you will get that "unknown type" return.

What you must do, is, for example, say you did 34 stages or something overnight out of 50, and you stopped it.

Run

opencv_traincascade -data data -vec positives.vec -bg bg.txt -numPos 1800 -numNeg 900 -numStages 34 -w 20 -h 20


and that will output the real XML file that you can use across languages.




-Harrison 7 years ago

You must be logged in to post. Please login or register an account.


Hi Harrison,
     My module only has 6 stages 0-5, I retrained again with -numStages 6.  In the data folder, it gave me stage0.xml - stage5.xml and cascade.xml.  I use newly generate cascade.xml in my c# program and it still give me the same error message.  Any idea?
Thanks a lot.

-derickloo 7 years ago

You must be logged in to post. Please login or register an account.